//
//  PopAnimateDelegate.swift
//  UIViewDemo
//
//  Created by 劢克科技 on 2019/3/8.
//  Copyright © 2019 劢克科技. All rights reserved.
//

import UIKit

class PopAnimateDelegate: NSObject {
    
    var gestureRecognizer: UIPanGestureRecognizer?
    
    let animatePresent = PopAnimatePresent()
    let animateDismiss = PopAnimateDismiss()
}

extension PopAnimateDelegate: UIViewControllerTransitioningDelegate {
    // 显示的动画对象
    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return animatePresent
    }
    
    // 隐藏的动画对象
    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return animateDismiss
    }
    
    // 隐藏的交互式对象
    func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
        if gestureRecognizer == nil {
            return nil
        } else {
            return PopAnimateInterDismiss(gesture: gestureRecognizer!)
        }
    }
}
